package cn.geminis.crypto.csp.soft.rsa;

import cn.geminis.crypto.core.key.PrivateKey;
import cn.geminis.crypto.core.key.PublicKey;
import cn.geminis.crypto.csp.AbstractDigest;
import cn.geminis.crypto.csp.soft.AbstractSoftSigner;
import cn.geminis.crypto.csp.soft.ec.Sha256Digest;
import org.bouncycastle.asn1.nist.NISTObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.bouncycastle.crypto.signers.RSADigestSigner;

/**
 * @author Allen
 */
public class Sha256WithRsaSigner extends AbstractSoftSigner {

    public Sha256WithRsaSigner(PublicKey publicKey, PrivateKey privateKey) {
        super(publicKey, privateKey);
    }

    @Override
    protected AbstractDigest createDigest() {
        return new Sha256Digest();
    }

    @Override
    protected org.bouncycastle.crypto.Signer createSigner() {
        return new RSADigestSigner(super.digest);
    }

    @Override
    public String getAlgOid() {
        return PKCSObjectIdentifiers.sha256WithRSAEncryption.toString();
    }

    @Override
    public String getDigestAlgOid() {
        return NISTObjectIdentifiers.id_sha256.toString();
    }
}
